import {  GET_ONE_ADDRESS,AMEND_ADDRESS } from '../types';
import { handleActions } from 'redux-actions';
import _ from 'lodash';

const Initdata = {
    _id:'',
    name:'',
    address:'',
    phone:0,
    Open_hours:'',
    longitude:0,
    latitude:0,
}

export const oneAddr = handleActions({
    // 获取对应_id的自提点数据
    [GET_ONE_ADDRESS]: (state, { payload }) => {
        const { name, address, phone, Open_hours, longitude, latitude, _id, imgs } = payload.data;
        return _.assign({}, state, {
            name, address, phone, Open_hours, longitude, latitude, _id, imgs
        })
    },
    
    // 修改
    [AMEND_ADDRESS]: (state, { payload }) => {
        // 
        const { name, address, phone, Open_hours, longitude, latitude, _id, imgs } = payload.data;
       
        return _.assign({}, state, {
            name, address, phone, Open_hours, longitude, latitude, _id, imgs
        })
    },

    



}, Initdata)